﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Configuration;
using DTO;

namespace CRM.GUI.HeThong
{
    public partial class frmSystemConfig : DevExpress.XtraEditors.XtraForm
    {
        public frmSystemConfig()
        {
            InitializeComponent();
            IntialLoad();
        }

        private void IntialLoad()
        {
            UserInfoEntity us = new UserInfoEntity();
            foreach (TreeNode node in trView.Nodes)
            {
                foreach (TreeNode child in node.Nodes)
                {
                    switch (child.Name)
                    { 
                        case "NodeTask":
                        if (us.Role >= 3)
                        {
                            trView.Nodes.Remove(child);
                        }
                        break;
                    }
                }
            }
            trView.ExpandAll();
        }

        private void trView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            switch (e.Node.Name)
            {
                case "NodeStore":
                    ucDownloadConfig general = new ucDownloadConfig();
                    panfield.Controls.Clear();
                    panfield.Controls.Add(general);
                break;

                case "NodeCall":
                    ucAsteriskConfig call = new ucAsteriskConfig();
                    panfield.Controls.Clear();
                    panfield.Controls.Add(call);
                break;

                case "NodeTask":
                    ucTaskConfig task = new ucTaskConfig();
                    panfield.Controls.Clear();
                    panfield.Controls.Add(task);
                break;

            }
        }


    }
}